
public class Vector2D {
	
	public double x , y;
	
	public Vector2D(double x, double y) {
		this.x = x;
		this.y = y;
		
	}
	
	public Vector2D(int x, int y) {
		this((double) x, (double) y);
	}
	
	public Vector2D() {
		this.x = 0;
		this.y = 0;
	}
	
	public int[] floorInt() {
		int v[] = new int[2];
		v[0] = (int) Math.floor(this.x);
		v[1] = (int) Math.floor(this.y);
		return v;
	}

	public double lenght() {
		return Math.sqrt(this.x * this.x + this.y * this.y);
	}
	
	public Vector2D normalize() {
		if(this.lenght() == 0) {
			System.out.println("normalize: length = 0");
			return this;
		}
		return new Vector2D(this.x / this.lenght(), this.y / this.lenght());
	}
	
	public double scalarMultiple(Vector2D v) {
		return (this.x * v.x + this.y * v.y);
	}
	
	public Vector2D scalarMultiple(double d) {
		return new Vector2D(this.x * d, this.y * d);
	}
	
	public Vector2D scalarMultiple(int i) {
		return scalarMultiple((double) i);
	}
	
	public Vector2D plus(Vector2D v) {
		return new Vector2D(this.x + v.x, this.y + v.y);
	}
	
	public Vector2D minus() {
		return new Vector2D(-this.x, -this.y);
	}
	
	public Vector2D perpendicular() {
		return new Vector2D((-this.y), this.x);
	}
	
	public String toString() {
		return  (' ' + String.valueOf(x) + ", " + String.valueOf(y));
	}
}
